|
|
|
| Set the Startup Object 1. Select Project, EmpInfo Properties from the Visual Basic menu. 2. On the General tab (shown in Figure 9.2), select from the Startup Object combo box either the form or Sub Main. Go ahead and select Sub Main. 3. Create a Sub Main() procedure in the BAS file. Be sure to make it a public sub so it can be called by the Visual Basic compiler. If you make it private, Visual Basic cant call it when the EXE starts up. 4. Add the following code to the Sub Main() procedure: | | Public Sub Main ()
frmEmployee.Show
End Sub |  | Now run the project. The Employee Information form should appear just like before. The only difference is you can now add other code to the Sub Main() that can execute before displaying your first form in your application. |
|
|
|
|
|
|
Its generally a good idea to begin your applications with Sub Main() instead of a startup form. If your first startup form has a lot of controls on it, the form can take quite awhile to load. This will cause a delay in the initial startup of your program. |
|
|
|
|
|
|
|
|
When you begin with Sub Main(), your application starts up right away because theres not a form to load, just a procedure. This means you could add a display of a splash screen while you load your Employee Information form. A splash screen does not generally have a lot of controls on it, so it can load quickly. Then, while its being displayed, you can load other forms. Heres an example of what this type of coding might look like: |
|
|
|
 |
|
|
|
|
Public Sub Main()
Screen.MousePointer = vbHourglass
' Display the Splash Screen
frmSplashScreen.Show
frmSplashScreen.Refresh
' Pre-Load the Employee Form
Load frmEmployee |
|
|
|
|
|